<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>$Title$</title>
</head>
<body>
<%
    String name = request.getParameter("name");
    if (name != null && !name.trim().equals("")) {
        Cookie cookie = new Cookie("name", name);
        cookie.setMaxAge(25);
        response.addCookie(cookie);
    } else {
        Cookie[] cookies = request.getCookies();
        if (cookies != null && cookies.length > 0) {
            for (Cookie cookie : cookies) {
                if ("name".equals(cookie.getName())) {
                    name = cookie.getValue();
                }
            }
        }
    }

    if (name != null && !name.trim().equals("")) {
        out.println("Hello:" + name);
    } else {
        response.sendRedirect("login.jsp");
    }
%>
</body>
</html>
